package org.example.service.impl;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.SmartInitializingSingleton;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

/**
 * @author zengxiaoyu
 * @date 2025/9/11 17:16
 */
@Component
public class B implements ApplicationContextAware, SmartInitializingSingleton {

    private ApplicationContext applicationContext;

    public B() {
        System.out.println("B init");
    }
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
        A a = applicationContext.getBean(A.class);
        C c = applicationContext.getBean(C.class);
        D d = applicationContext.getBean(D.class);
        E e = applicationContext.getBean(E.class);
        System.out.println("BE afterSingletonsInstantiated:");
        System.out.println(e);
    }

    @Override
    public void afterSingletonsInstantiated() {

    }
}
